
<div class="span12">
	<div class="box gradient">
	 <input type="hidden" class="filterdata" field="attrOption.id" op="eq" value="${entity.id}"> 
	 
		<div class="title">
				<h4>
				<span>Option </span> <span class="box-form right"> </span>
				
				<span class="box-form right optionValue_bar"><a href="#" class="btn btn-mini addOptionValue">Add Option Value</a></span>
 				</h4>
 				<a href="#" class="minimize"> </a>
			</div>
		 <div class="content scrollable clearfix">
		<table class="table table-bordered table-vertical-centre optionValueTable">
			<thead>
				<tr>
					<th><a class="select_all"><span class="icomoon-icon-checkmark-2"></span></a></th>
				<th>Name </th>
				<th>Image  </th>
				<th>Order  </th>
 				<th>Action</th>
				</tr>
			</thead>
		</table>
		</div>
	 
</div>
 </div>
<script type="text/javascript" src="/ckfinder/ckfinder.js"></script>
 <script>
 
 

$(document).ready(function(){

	
	
	
	
	
	var del = {
			id : 'optionValueDel',
			text  : 'Del',
			domain : "Option Value",
			operation : "Del",
			url : "${ctx}/admin/option-value/del/",
			selector : ".optionValue_bar",
			selects  : $('.optionValueTable'),
	  
	};
	johnny.tableBtn(del);
	
 	
	
	$('.addOptionValue').click(function(){
		$("#optionValueDiv").find("div.modal-body").find("input,select,textarea,checkbox").not("[name=action]").each(function(step,value){
				$(value).val("");
		});	
		
		
	 $("#optionValueDiv input[name='action']").val("${ctx}/admin/option-value/${entity.id}/create/");
 	 $("#optionValueDiv").modal('show');
  });
	
	  $(document).delegate('.optionValueTable .icomoon-icon-pencil', 'click', function(event) {
		  
		  	var id = $(this).parent().attr("dataid");
			$.ajax({
				url : "${ctx}/admin/option-value/"+id+"/edit/",
				type : "GET",
				dataType : "json",
				success : function(data){		
					if(data && data.state && (data.state.indexOf("ERROR") != -1)){
						johnny.error(data.message);
						return;
					}else{
							var entity = data.entity;
 							
							$("#optionValueDiv").find("div.modal-body").find("input,select,textarea,checkbox").not("[name=action]").each(function(step,value){
									var name = $(value).attr("name");
 									if (entity[name]){
										$(value).val(entity[name]);
									}else{
 										$(value).val("");
									}
								
							});
							
  							$("#optionValueDiv input[name='action']").val("${ctx}/admin/option-value/"+id+"/edit/");
     	    				$("#optionValueDiv").modal('show');
 					}
				}
			});		  
 
	     
	    });
	var recordColumn = ['','name','image'];
	
	 $('.optionValueTable').dataTable({
		"bLengthChange" : true,
		"aoColumnDefs" : [ {
			'bSortable' : false,
			'aTargets' : [0,4 ]
		} ],
 		"sAjaxSource" : '${ctx}/admin/option-value/',
		"createQueryData" : function (aoData){
				return	johnny.initQueryData(aoData, recordColumn);
		},
		"createResult" : function (json, echo){
 			var dataArray = new Array();
			for ( var i = 0; i < json.result.length; i++) {
				var subArray = new Array();
				var value = johnny.getForSelect(json.result[i].id);
				subArray.push(value);
				subArray.push(json.result[i].name)
				subArray.push(johnny.getImageHtml(json.result[i].image));
				subArray.push(json.result[i].orderRank) ;

   				var conf = [{
					link : 'javascript:void(1)',
					dataId : json.result[i].id,
					text : 'edit',
					css  : 'icomoon-icon-pencil'
				} 
				
				];
				subArray.push(johnny.getGridLink(conf)); 
  				dataArray.push(subArray);
			}
			return {
				sEcho : echo,
				iTotalRecords : json.totalCount,
				iTotalDisplayRecords : json.totalCount,
				aaData : dataArray
			};
		}		
	});
	 
	
	
	
	
});


</script>





<div id="optionValueDiv" class="modal hide fade"  selector=".optionValueTable" style="display: none; ">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal">
			<span class="icon12 minia-icon-close"></span>
		</button>
		<h3>	Option Value  </h3>
	</div>
 
	<div class="modal-body">
  						<input type="hidden" name="action" >
 						<!--name --><div class="form-row row-fluid"><div class="span12"><div class="row-fluid"><label class="form-label span3" for="name">Name :</label><input class="span4" id="name" name="name"   type="text" value="" /></div></div></div>
						<!--image --><div class="form-row row-fluid"><div class="span12"><div class="row-fluid"><label class="form-label span3" for="image">Image :</label><input class="span4" id="image" name="image"   type="text" value="" /></div></div></div>
 						<!--order rank --><div class="form-row row-fluid"><div class="span12"><div class="row-fluid"><label class="form-label span3" for="name">Order Rank :</label><input class="span4" id="name" name="orderRank"   type="text" value="" /></div></div></div>

						 
	</div>
	 
	<div class="modal-footer">
		<a href="#" class="btn" data-dismiss="modal">Close</a>
		<a href="#" class="btn btn-primary modal-submit">Save changes</a>
	</div>

</div>
